<?php
import("ORG.Util.Page"); // 导入分页类
class SF_PAGE extends Think {
	//const STYLE_ADMIN = '<div class="think_page_pos"><span class="think_page_content"> %totalRow% %header% %nowPage%/%totalPage% 页</span> <span class="think_page">%upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end% </span></div><div style="clear:both"></div>';
	const STYLE_ADMIN = '<div class="pagination" targetType="navTab" totalCount="%totalRow%" numPerPage="3" pageNumShown="10" currentPage="%nowPage%"></div>';
	/**
	 * 
	     +----------------------------------------------------------
		  * 数据分页显示类(一般样式）
		 +----------------------------------------------------------
		 *@param unknown_type $model 模型类对象
		 *@param unknown_type $pageStyle 页码
		 *@param unknown_type $condition 查询条件
		 *@param boolean $relation 是否关联查询
	 */
	static function page($model, &$pageStyle,$order = 'id asc',$condition = '',$relation = false , $style = null  ){		
		$count = $model->where($condition)->count();
		$Page = new Page($count, 3);
		$list = $model->where($condition)->limit($Page->firstRow.','.$Page->listRows)->order($order);
		$list = $relation == true ? $list->relation(true)->select() : $list->select();
		if($style != null)
			$Page->setConfig('theme',$style);
		
		$pageStyle = $Page->show();
		
		return $list;
	}	
}
